package org.springboot.szsrcb.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springboot.szsrcb.entity.Req_base_info;
import org.springboot.szsrcb.entity.Req_bill;
import org.springboot.szsrcb.srvice.Req_bill_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/test")
public class TestController_assign {

	private static final Logger logger = LoggerFactory.getLogger(TestController_assign.class);

	@Autowired
	private Req_bill_Service req_bill_Service;

	@RequestMapping("/test_reject")
	public String test_reject(HttpServletRequest request, Model model, HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_reject");
			String test_id = request.getParameter("test_id");
			model.addAttribute("test_id", test_id);
			// model.addAttribute("name", name);
			return "test_reject";

		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_assign")
	public String test_assign(HttpServletRequest request, Model model, HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_assign");
			String test_id = request.getParameter("test_id");
			model.addAttribute("test_id", test_id);
			// model.addAttribute("name", name);
			return "test_assign";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_assign_list")
	public String test_assign_list(HttpServletRequest request, HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_assign_list");

			return "test_assign_list";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

	@RequestMapping("/test_assign_select_req")
	public String test_assign_select_req(HttpServletRequest request, Model model, HttpSession httpSession) {
		String login_name = (String) httpSession.getAttribute("login_name");
		if (login_name != null) {
			logger.info("test_assign_select_req");
			// model.addAttribute("name", name);
			String params = request.getParameter("params");
			String[] s = params.split(",", 3);
			logger.info("test_assign_select_req params =" + params);
			model.addAttribute("req_title", s[0]);
			model.addAttribute("req_bill_no", s[1]);
			model.addAttribute("technical_director", s[2]);
			return "test_assign_select_req";
		} else {
			logger.info("access login page.");
			return "/login";
		}
	}

}
